fix(particlesys): Add or simplify null-checks to createParticleSystem calls#2724
fix(particlesys): Add or simplify null-checks to createParticleSystem calls#2724stephanmeesters wants to merge 4 commits into
Conversation
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Source/GameClient/System/ParticleSys.cpp | Simplifies two call sites: moves createParticleSystem call before the null-template guard in update(), and removes the null-template guard entirely in createSlaveSystem(). Both are safe — the function already returns nullptr for a null template argument. |
| Core/GameEngine/Source/GameClient/Drawable/Update/BeaconClientUpdate.cpp | Collapses the double-null-check around the failsafe path; technically safe since createParticleSystem handles nullptr, but this specific change has an ongoing discussion in the thread and a senior developer has requested a revert. |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/ChinookAIUpdate.cpp | Removes the template null-guard correctly, but introduces mixed tab/space indentation on the if(system) block, breaking consistency with surrounding code. |
| Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptEngine.cpp | Removes the parentTemp null-guard before createParticleSystem; safe because createParticleSystem returns nullptr for a null template, preserving the original skip-if-not-found behaviour. |
| GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptEngine.cpp | Same simplification as Generals/ScriptEngine.cpp — null-template guard removed, createParticleSystem handles nullptr safely. |
| Generals/Code/GameEngine/Source/GameLogic/Object/Update/StealthDetectorUpdate.cpp | Removes both the outer m_IRGridParticleSysTmpl guard and the inner redundant check, collapsing to a single createParticleSystem + null result check. Functionally equivalent. |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StealthDetectorUpdate.cpp | Keeps the outer m_IRGridParticleSysTmpl guard (unlike the Generals counterpart) and removes only the inner redundant check. Functionally identical; minor stylistic inconsistency between the two codebases. |
| Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankTruckDraw.cpp | Separates the template lookup and creation calls, guarding only on the system result. Correct and safe. |
| Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTruckDraw.cpp | Same pattern as W3DTankTruckDraw — template lookup and system creation separated, null-check on system result only. Clean. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
subgraph Before ["Before (old pattern)"]
A[findTemplate name] --> B{template != nullptr?}
B -- No --> Z[Skip]
B -- Yes --> C[createParticleSystem template]
C --> D{system != nullptr?}
D -- No --> Z
D -- Yes --> E[Use system]
end
subgraph After ["After (new pattern)"]
A2[findTemplate name] --> C2[createParticleSystem template]
C2 --> D2{system != nullptr?}
D2 -- No --> Z2[Skip]
D2 -- Yes --> E2[Use system]
end
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/ChinookAIUpdate.cpp:1202-1206
Indentation inconsistency introduced — the `if( system )` block now uses a different tab/space mix than the `tmp` and `system` declarations directly above it. The declaration lines use one tab + six spaces, while the `if` body uses two tabs + two spaces. This breaks the visual alignment present in the surrounding code and the original indentation style.
```suggestion
ParticleSystem *system = TheParticleSystemManager->createParticleSystem( tmp );
if( system )
{
system->setPosition( &pos );
}
```
Reviews (4): Last reviewed commit: "Replicate in Generals" | Re-trigger Greptile
|
Replicated: ChinookAIUpdate.cpp and EMPUpdate.cpp don't exist in Generals, LaserUpdate.cpp and StealthDetectorUpdate.cpp diverge a bit. |
createParticleSystemis null checkedTodo